﻿Ext.define('app.prm.document.Edit',
{
    extend: 'Ext.window.Window',
    title: '上传文档',
    autoScroll: true,
    modal: true,
    width: 400,
    height: 200,
    layout: 'fit',
    documentId: 0,
    bodyStyle: 'padding:30px',
    initComponent: function () {
        var me = this;
        me.items = [me.getUploadForm()];
        me.buttons = [
            { text: '确定', scope: this, handler: me.onSave },
            { text: '关闭', handler: function () { me.close(); } }
        ]
        me.callParent();
    },
    getUploadForm: function () {
        if (!this.uploadForm) {
            this.uploadForm = new Ext.form.Panel({
                border: false,
                items: [
                    {
                        xtype: 'filefield', width: 300, name: 'VersionFile', buttonText: '上传'
                    }
                ]
            });
        }
        return this.uploadForm;
    },
    onSave: function () {
        var me = this;
        me.getUploadForm().getForm().submit({
            url: '/api/services/app/document/EditDocument',
            params: { DocumentId: me.documentId },
            success: function (form, response) {
                me.fireEvent("savesuccess");
            }
        });
    }
});